



var app = getApp()
const db = wx.cloud.database({
  env: "treeworld-2g5yvz9s899bf4a6"
})
const _ = db.command

Component({
  data: {},
  methods:{

  post() {
    db.collection('Book').get().then(res => {
      console.log(res.data)
      this.setData({
        list: res.data
      })
    })
    console.log(this.data.list)
  },

  tz (e) {
    console.log(e.currentTarget.dataset)
    this.setData({
      urlshow:e.currentTarget.dataset.url
    })

    wx.downloadFile({
      // 示例 url，并非真实存在
      url: e.currentTarget.dataset.url,
      filePath:`${wx.env.USER_DATA_PATH}/`+e.currentTarget.dataset.tille+'.pdf',
      success: function (res) {
        const filePath = res.filePath
        console.log(filePath)
        wx.openDocument({
          filePath: filePath,
          showMenu:true,
          success: function (res) {
            console.log('打开文档成功')
          }
        })
      }
    }).onProgressUpdate((res)=>{
      this.setData({
        tl:res.progress
      })
      console.log(res.progress);
  })
  },
  },
  created() {
    this.post()
    wx.getSavedFileList({
      success (res) {
        console.log(res)
      }
    })
  },
   
  




    
})